<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8">
            <title>当前视野搜索</title>
            <link rel="stylesheet" type="text/css" href="__PUBLIC__/style.css" />
            <style type="text/css">
                #map {
                    width:520px;
                    height:500px;
                }
                    
                #option{
                    height:20px;
                    width:500px;
                    border:solid 1px #CCCCCC;
                    padding:10px;
                }
            </style>
            <script type="text/javascript" src="http://api.go2map.com/maps/js/api_v2.0.js"></script>
            <script src="__PUBLIC__/js/jquery.js" type="text/javascript"></script>
            <script src="__PUBLIC__/js/common.js" type="text/javascript"></script>     
    </head>
    <body>
        <div id="option">
            地址：<input class="input-text" type="text" id="kw"  size="55" value="{$address}" />
            <input class="button01-out" type="button"  value="查询" onclick="search()" />
        </div>
        <div id="map"></div>
    </body>
    <script type="text/javascript">
        /**
         *地址解析
         */
        var marker = null;
        
        var myLatLng = new sogou.maps.Point(12957062,4827187);
        var myOptions = {
            zoom: 10,
            center: myLatLng
        };
        var map = new sogou.maps.Map(document.getElementById("map"), myOptions);
        
        function callback(a){
            if (marker) {
                marker.setMap(null);
            }
            if(a.status='ok'){
                var data = a.data;
                if (data.length > 0) {
                    var geometry=data[0];
                    marker = new sogou.maps.Marker({
                        map:map,
                        title:geometry.address,
                        label:{
                            title:geometry.address,
                            visible:true
                        },
                        position:geometry.location,
                        visible:true
                    });
                    
                    map.setCenter(marker.getPosition());
                }
            }
            
        }
        
        function search(){
            var kw = document.getElementById("kw").value;
            var request={
                address:{
                    addr:kw,
                    city:"全国"
                }
            }
            var geo=new sogou.maps.Geocoder();
            geo.geocode(request,callback);
        }
    </script>
</html>